import ui.QueryTableNamePanel;
import ui.QueryValidateRecordPanel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

public class MainUi {

    private JFrame jf;

    public MainUi(){
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        this.jf = new JFrame("二代征信报送助手");
        this.jf.setSize(640,480);
        this.jf.setDefaultCloseOperation(3);
        Dimension myframe = this.jf.getSize();
        int w = (screen.width - myframe.width) / 2;
        int h = (screen.height - myframe.height) / 2;
        this.jf.setLocation(w,h);


        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.addTab("征信对应表名查询(CTRL+1)",new QueryTableNamePanel());
        tabbedPane.setEnabledAt(0,true);
        tabbedPane.registerKeyboardAction(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e)
            {
                tabbedPane.setSelectedIndex(0);
            }
        }, KeyStroke.getKeyStroke( KeyEvent.VK_1 ,KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

        tabbedPane.addTab("征信对应校验规则查询(CTRL+2)",new QueryValidateRecordPanel());
        tabbedPane.setEnabledAt(1,true);
        tabbedPane.registerKeyboardAction(new ActionListener(){
            @Override
            public void actionPerformed(ActionEvent e)
            {
                tabbedPane.setSelectedIndex(1);
            }
        }, KeyStroke.getKeyStroke( KeyEvent.VK_2 ,KeyEvent.CTRL_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW);

        this.jf.setContentPane(tabbedPane);
        this.jf.setVisible(true);
    }



    public static void main(String args[]){
        try{
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            new MainUi();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
